<?php

use yii\db\Migration;
use yii\db\Schema;

class m170606_091105_CREATE_TABLE_ORDER_ASSIGN extends Migration
{
    public function up()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        // 分团表
        $this->createTable('order_assign', [
            "id" =>         Schema::TYPE_PK,
            "product_id"=>  Schema::TYPE_INTEGER.   "(5) DEFAULT  '0' COMMENT '团期编号'",
            "order_id"=>  	Schema::TYPE_INTEGER.   "(9) DEFAULT  '0' COMMENT '订单编号'",
            "name" =>       Schema::TYPE_STRING.    "(32) NULL COMMENT '名称'",

            "status" =>     Schema::TYPE_INTEGER.   "(1) DEFAULT  '1' COMMENT '1正常  2禁用'",
            "user_id" =>    Schema::TYPE_INTEGER.   "(10) DEFAULT '0' COMMENT '管理员编号'",
            "created_at" => Schema::TYPE_DATETIME. " NULL",
            "updated_at" => Schema::TYPE_TIMESTAMP. " NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
        ], $tableOptions);

		// 
        $this->addColumn('{{order}}', 'assign_id', Schema::TYPE_INTEGER. "(9)  NULL  COMMENT '分团的编号' ");

    }

    public function down()
    {
        echo "m170606_091105_CREATE_TABLE_ORDER_ASSIGN cannot be reverted.\n";

        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
